package group2assignone.ucm.customer;

import group2assignone.model.Customer;
import group2assignone.ucm.UCController;
import group2assignone.view.OurView;
import group2assignone.view.customer.CustomerWelcomeView;

/**
 * Use Case: Cancel Customer 
 * Pre-condition: Customer is logged in and clicks the 'cancel' button 
 * from within a customer view.
 * Post-condition: Main customer welcome menu is displayed.
 * 1. system creates the new Customer welcome view
 * 2. system opens the new Customer welcome view
 * 3. system exits the current view
 * @author group2
 */
public class UCCancelCustomer implements UCController {

    private OurView view;
    private Customer cust;

    /**
     * sets the customer and view, used for personalisation
     * @param cust
     * @param view
     */
    public UCCancelCustomer(Customer cust, OurView view) {
        this.cust = cust;
        this.view = view;
    }

    /**
     * Takes the customer back to the customer welcome view
     */
    public void run() {
        // 1. system creates the new Customer welcome view
        CustomerWelcomeView gui = new CustomerWelcomeView(cust);
        gui.go();       // 2. system opens the new Customer welcome view
        view.dispose(); // 3. system exits the current view
    }
}
